package com.yidu.BusinessData.controller;

import com.yidu.BusinessData.entity.SecurityEntity;
import com.yidu.BusinessData.entity.StockEntity;
import com.yidu.BusinessData.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**@description: 板块分类控制器
 *@author: 肖理
 *@create: 2022-09-10
 **/
@RestController
public class StockController {
    @Autowired
    StockService stockService;

    //板块分类查询
    @RequestMapping("/selectstock")
    public Map selectStock(String stockName){
        Map map = new HashMap();
        System.out.println("你好");
        List<StockEntity> stockEntityList= stockService.selectStock(stockName);
        System.out.println(stockEntityList);
        map.put("code","0");
        map.put("msg","成功");
        map.put("count",0);
        map.put("data",stockEntityList);
        return map;
    }

    @RequestMapping("/selectstocktwo")
    public Map selectStocktwo(){
        Map map = new HashMap();
        System.out.println("你好");
        List<StockEntity> stockEntityList= stockService.selectStocktwo();
        System.out.println(stockEntityList);
        map.put("code","0");
        map.put("msg","成功");
        map.put("count",0);
        map.put("data",stockEntityList);
        return map;
    }

    @RequestMapping("/selectstockthree")
    public Map selectStockthree(){
        Map map = new HashMap();
        System.out.println("你好");
        List<StockEntity> stockEntityList= stockService.selectStockthree();
        System.out.println(stockEntityList);
        map.put("code","0");
        map.put("msg","成功");
        map.put("count",0);
        map.put("data",stockEntityList);
        return map;
    }
    //板块分类增加
    @RequestMapping("/insertstock")
    public String insertStock(StockEntity stockEntity){
        if (stockEntity.getStockFatherId()==null){
            stockEntity.setStockFatherId("000");
        }
        int i = stockService.insertStock(stockEntity);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
    //板块分类删除
    @RequestMapping("/deletestock")
    public String deleteStock(String stockId){
        int i = stockService.deleteStock(stockId);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
    //板块分类修改
    @RequestMapping("/updatestock")
    public String updateStock(StockEntity securityEntity){
        int i =stockService.updateStock(securityEntity);
        System.out.println(i);
        if (i>0) {
            return "ok";
        }else {
            return "no";
        }
    }
}
